package com.kinyx.framework.db.sentence.res;

import com.kinyx.framework.annotation.assist.Tester;
import com.kinyx.framework.db.configs.DBConfigs;
import com.kinyx.framework.db.sentence.LikeType;

import lombok.AccessLevel;
import lombok.Getter;

/**
 * 模糊匹配型表达式子句
 */
@Tester("com.kinyx.framework.db.sentence.res._Expression_LIKE_Tester_")
class _Expression_LIKE extends _Expression {

	/** 参数 */
	@Getter(value = AccessLevel.PACKAGE)
	private final String param;

	_Expression_LIKE(final Column column, final boolean like, final LikeType likeType, final String param) {
		super(column, like ? "LIKE" : "NOT LIKE");
		this.param = likeType.formatParam(param);
	}

	@Override
	public String getSentence(final DBConfigs configs, final boolean isSQL, final boolean withTableAlias) {
		return super.getSentence(configs, isSQL, withTableAlias) + " " + "?";
	}

	@Override
	public String toString() {
		return super.toString() + String.format(", param: [%s]", String.valueOf(this.param));
	}

}
